<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">


    /**
     * 用户自定义构造函数的本质，底层调用的是 Object这个构造函数。
     * @param n
     * @param a
     * @constructor
     */
    function People(n, a) {
        this.username = n;
        this.age = a;
    }

    /*

    var p1 = new People('andy', 23);
    底层 等价
    function People(n, a) {
        var o =  new Object();

        o.username = n;
        o.age = a;

        return o;
    }
    var p1 = People('andy', 23);

    * */

    var p1 = new People('andy', 23);
    console.log(p1);
    console.log(p1.username);
    console.log(p1.age);

</script>

</html>
